From: Felix Fietkau Date: Sat, 23 Aug 2025 19:46:17 +0000 (+0200) Subject: ucode: add function for getting the number of entries in a snapshot X-Git-Url: http://git.openwrt.org/%22https:/collectd.org//%22http:/www.crowdsec.net/%22/%22https:/collectd.org/%22http:/www.crowdsec.net/%22?a=commitdiff_plain;h=6e4ffe2c66578f5d497fb3f7e377079d3507cc38;p=project%2Fudebug.git ucode: add function for getting the number of entries in a snapshot Signed-off-by: Felix Fietkau --- diff --git a/lib-ucode.c b/lib-ucode.c index 00ab1c8..b905cbe 100644 --- a/lib-ucode.c +++ b/lib-ucode.c @@ -467,6 +467,17 @@ uc_udebug_snapshot_get_ring(uc_vm_t *vm, size_t nargs) return ucv_get(rb->priv); } +static uc_value_t * +uc_udebug_snapshot_entries(uc_vm_t *vm, size_t nargs) +{ + struct udebug_snapshot *s = uc_fn_thisval("udebug.snapshot"); + + if (!s) + return NULL; + + return ucv_int64_new(s->n_entries); +} + static uc_value_t * uc_udebug_foreach_packet(uc_vm_t *vm, size_t nargs) { @@ -667,7 +678,8 @@ static const uc_function_list_t pcap_fns[] = { }; static const uc_function_list_t snapshot_fns[] = { - { "get_ring", uc_udebug_snapshot_get_ring } + { "get_ring", uc_udebug_snapshot_get_ring }, + { "entries", uc_udebug_snapshot_entries } }; static const uc_function_list_t wbuf_fns[] = {